import moment from 'moment';
import mockjs from 'mockjs';
import type { Request, Response } from 'express';
import type { AnalysisData, RadarData, DataItem } from './data.d';

// mock data

const visitData2 = [];
const fakeY2 = [1, 6, 4, 8, 3, 7, 2];
for (let i = 0; i < fakeY2.length; i += 1) {
  visitData2.push(fakeY2[i]);
}

const searchData = [];
for (let i = 0; i < 50; i += 1) {
  searchData.push({
    index: i + 1,
    keyword: `岗位${i}`,
    count: Math.floor(Math.random() * 1000),
    range: Math.floor(Math.random() * 100),
    status: Math.floor((Math.random() * 10) % 2),
  });
}

const avatars2 = [
  'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png',
  'https://gw.alipayobjects.com/zos/rmsportal/cnrhVkzwxjPwAaCfPbdc.png',
  'https://gw.alipayobjects.com/zos/rmsportal/gaOngJwsRYRaVAuXXcmB.png',
  'https://gw.alipayobjects.com/zos/rmsportal/ubnKSIfAJTxIgXOKlciN.png',
  'https://gw.alipayobjects.com/zos/rmsportal/WhxKECPNujWoWEFNdnJE.png',
  'https://gw.alipayobjects.com/zos/rmsportal/jZUIxmJycoymBprLOUbT.png',
  'https://gw.alipayobjects.com/zos/rmsportal/psOgztMplJMGpVEqfcgF.png',
  'https://gw.alipayobjects.com/zos/rmsportal/ZpBqSxLxVEXfcUNoPKrz.png',
  'https://gw.alipayobjects.com/zos/rmsportal/laiEnJdGHVOhJrUShBaJ.png',
  'https://gw.alipayobjects.com/zos/rmsportal/UrQsqscbKEpNuJcvBZBu.png',
];

const getActivities = (_: Request, res: Response) => {
  res.json({
    data: [
      {
        id: 'trend-1',
        updatedAt: new Date(),
        user: {
          name: '曲丽丽',
          avatar: avatars2[0],
        },
        group: {
          name: '信息与控制学院',
          link: 'http://github.com/',
        },
        project: {
          name: '软件工程方向教师',
          link: 'http://github.com/',
        },
        template: '在 @{group} 新建招聘计划 @{project}',
      },
      {
        id: 'trend-2',
        updatedAt: new Date(),
        user: {
          name: '付小小',
          avatar: avatars2[1],
        },
        group: {
          name: '信息与控制学院',
          link: 'http://github.com/',
        },
        project: {
          name: '软件工程方向教师',
          link: 'http://github.com/',
        },
        template: '在 @{group} 新建招聘计划 @{project}',
      },
      {
        id: 'trend-3',
        updatedAt: new Date(),
        user: {
          name: '林东东',
          avatar: avatars2[2],
        },
        group: {
          name: '人文与国际交流学院',
          link: 'http://github.com/',
        },
        project: {
          name: '教学系列讲师（英语）',
          link: 'http://github.com/',
        },
        template: '在 @{group} 新建招聘计划 @{project}',
      },
      {
        id: 'trend-4',
        updatedAt: new Date(),
        user: {
          name: '周星星',
          avatar: avatars2[4],
        },
        project: {
          name: '5 位',
          link: 'http://github.com/',
        },
        template: '审核通过了 @{project} 资格审查候选人',
      },
      {
        id: 'trend-5',
        updatedAt: new Date(),
        user: {
          name: '朱偏右',
          avatar: avatars2[3],
        },
        project: {
          name: '陶白白',
          link: 'http://github.com/',
        },
        template: '淘汰了 @{project} 的简历',
      },
      {
        id: 'trend-6',
        updatedAt: new Date(),
        user: {
          name: '乐哥',
          avatar: avatars2[5],
        },
        group: {
          name: '艺术与设计学院',
          link: 'http://github.com/',
        },
        project: {
          name: '辅导员',
          link: 'http://github.com/',
        },
        template: '在 @{group} 新建招聘计划 @{project}',
      },
    ],
  });
};

const getFakeChartData: AnalysisData = {
  visitData2,
  searchData,
};

const fakeChartData = (_: Request, res: Response) => {
  return res.json({
    data: getFakeChartData,
  });
};

const getTags = (_: Request, res: Response) => {
  return res.json({
    data: mockjs.mock({
      'list|100': [{ name: '@city', 'value|1-100': 150, 'type|0-2': 1 }],
    }),
  });
};

export default {
  'GET  /api/fake_analysis_chart_data': fakeChartData,
  'GET  /api/activities': getActivities,
  'GET  /api/tags': getTags,
};
